/**
 * A view that display a User profile
 * 
 */
qx.Class.define("bip.ui.users.UserProfile",
{
  extend : qx.ui.core.Widget,

  /*
  *****************************************************************************
     CONSTRUCTOR
  *****************************************************************************
  */

  /**
   * Construct the view
   * @param userModel {bip.rpc.User} The user rpc proxy model
   */
  construct : function(userModel) {
    if ((qx.core.Environment.get("qx.debug"))) {
      this.assertArgumentsCount(arguments, 1, 1);
    }
    
    this.base(arguments);
	
	this.setModel(userModel);
    this._setLayout(new qx.ui.layout.VBox());
	
	// force creation of ui elements
    this._createChildControl("username");	
	
  },

  /*
  *****************************************************************************
     PROPERTIES
  *****************************************************************************
  */

  properties :
  {
  	// overridden
    appearance :
    {
      refine : true,
      init : "userprofile"
    },
	
	model : {
	  	check: "bip.rpc.User",
	  	nullable : true	
	}
	
  },

  /*
  *****************************************************************************
     MEMBERS
  *****************************************************************************
  */

  members :
  {
	
  	/*
  	*****************************************************************************
     HANDLERS
  	*****************************************************************************
 	*/
	
  	/*
  	*****************************************************************************
     UI
  	*****************************************************************************
 	*/
    // overridden
    _createChildControlImpl : function(id) {
	      var control;
	      switch(id) {	
			case "groupbox":
				var layout = new qx.ui.layout.Grid(8, 8);
				control = new qx.ui.groupbox.GroupBox("User Profile");
				//control.setWidth(290);
			    control.setLayout(layout);
				this._add(control);
				break;
			
			case "username":
				control = new qx.ui.form.TextField();
			    control.setPlaceholder("username");
			    var label = new qx.ui.basic.Label("Username");
			    label.setWidth(100);
			    label.setBuddy(control);
			    this.getChildControl("groupbox").add(label, {row: 0, column: 0});
			    this.getChildControl("groupbox").add(control, {row: 0, column: 1});
				this.getModel().bind("name",control,"value");
				break;
	      }
	      return control || this.base(arguments, id);
	    }

	/*
    ---------------------------------------------------------------------------
      PROPERTY APPLY ROUTINES
    ---------------------------------------------------------------------------
    */

  }
  
});